package dao

import (
	"demo/models"

	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
)

//var dsn string = "root:chengxun@tcp(25.30.15.85:3306)/cube-go?charset=utf8mb4&parseTime=True&loc=Local"
var dsn = "gorm.db"

// 初始化数据库表
func init() {
	db := GetDB()
	db.AutoMigrate(&models.SysUser{})
}

func GetDB() (db *gorm.DB) {
	db, err := gorm.Open(sqlite.Open(dsn))
	if err != nil {
		panic("failed to connect database!")
	}
	return db
}
